using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace EditorExtensions
{
    public static class MenuItemExample
    {
        [MenuItem("EditorExtensions/01.Menu/01.Hello Editor")]
        static void HelloEditor()
        {
            Debug.Log("Hello Editor");
        }

        [MenuItem("EditorExtensions/01.Menu/02.OpenBiliBili")]
        static void OpenBiliBili()
        {
            Application.OpenURL("https://www.bilibili.com/?spm_id_from=333.1365.0.0");
        }

        [MenuItem("EditorExtensions/01.Menu/03.PersistentDataPath")]
        static void OpenPersistentDataPath()
        {
            EditorUtility.RevealInFinder(Application.persistentDataPath);
        }

        [MenuItem("EditorExtensions/01.Menu/04.打开策划目录--和Assets处于同一目录")]
        static void OpenDesignerFolder()
        {
            EditorUtility.RevealInFinder(Application.dataPath.Replace("Assets", "Library"));
        }

        private static bool mOpenShotCut = false;

        [MenuItem("EditorExtensions/01.Menu/05.快捷键开关")]
        static void ToggleShotCut()
        {
            mOpenShotCut = !mOpenShotCut;
            Menu.SetChecked("EditorExtensions/01.Menu/05.快捷键开关", mOpenShotCut);
        }

        [MenuItem("EditorExtensions/01.Menu/06.Hello Editor _c")]
        static void HelloEditorWithShotCut()
        {
            EditorApplication.ExecuteMenuItem("EditorExtensions/01.Menu/01.Hello Editor");
            //HelloEditor();
        }

        [MenuItem("EditorExtensions/01.Menu/06.Hello Editor _c", validate = true)]
        static bool HelloEditorWithShotCutValidate()
        {
            return mOpenShotCut;
        }

        [MenuItem("EditorExtensions/01.Menu/07.OpenBiliBili %e")]
        static void OpenBiliBiliWithShotCut()
        {
            EditorApplication.ExecuteMenuItem("EditorExtensions/01.Menu/02.OpenBiliBili");
        }

        [MenuItem("EditorExtensions/01.Menu/07.OpenBiliBili %e", validate = true)]
        static bool OpenBiliBiliWithValidate()
        {
            return mOpenShotCut;
        }

        [MenuItem("EditorExtensions/01.Menu/08.PersistentDataPath %#t")]
        static void OpenPersistentDataPathWithShotCut()
        {
            EditorApplication.ExecuteMenuItem("EditorExtensions/01.Menu/03.PersistentDataPath");
        }

        [MenuItem("EditorExtensions/01.Menu/08.PersistentDataPath %#t", validate = true)]
        static bool OpenPersistentDataPathWithValidate()
        {
            return mOpenShotCut;
        }

        [MenuItem("EditorExtensions/01.Menu/09.打开策划目录 &r")]
        static void OpenDesignerFolderWithShotCut()
        {
            EditorApplication.ExecuteMenuItem("EditorExtensions/01.Menu/04.打开策划目录--和Assets处于同一目录");
        }

        [MenuItem("EditorExtensions/01.Menu/09.打开策划目录 &r", validate = true)]
        static bool OpenDesignerFolderWithValidate()
        {
            return mOpenShotCut;
        }

        //每次编译都会调用一次1
        static MenuItemExample()
        {
            Menu.SetChecked("EditorExtensions/01.Menu/05.快捷键开关", mOpenShotCut);
        }
    }
}